package reflect;

import java.util.Arrays;

/**
 * 可变长参数
 */
public class ArgsDemo {
    public static void main(String[] args) {
        dosome(1,"a");
        dosome(1,"a","b");
        dosome(1,"a","b","c");
        dosome(1,"a","b","c","a","b","c","a","b","c","a","b","c","a","b","c","a","b","c","a","b","c","a","b","c","a","b","c","a","b","c","a","b","c","a","b","c");
    }
    /*
        变长参数会被编译器改为数组。
        变长参数只能是方法的【最后一个】参数。
     */
    public static void dosome(int d,String... s){
        System.out.println(s.length);
        System.out.println(Arrays.toString(s));
    }
}
